<template>
  <div class="index">
    <!-- 课程列表 -->
    <div class="index_curriculum">
      <curriculum :infoitem='index_list'></curriculum>
    </div>
    <div class="kong"></div>
  </div>
</template>

<script>
import {
  Search,
  Group,
  Cell,
  XButton,
  Swiper,
  SwiperItem
} from 'vux'
import curriculum from '@/components/curriculum/curriculum.vue'
import Cookies from 'js-cookie'
import api from '@/api/api'
import { mapState } from 'vuex'
export default {
  data () {
    return {
      indexObj: {
        app_id: '',
        user_id: ''
      },
      demo01_index: 0,
      bannerlist: [],
      classification: [],
      hotimage: [
        'http://o6wndwjxn.qnssl.com/10bc2201810181324424582.jpg',
        'http://o6wndwjxn.qnssl.com/10bc2201810181324424582.jpg',
        'http://o6wndwjxn.qnssl.com/10bc2201810181324424582.jpg'
      ],
      education: {
        image: 'http://o6wndwjxn.qnssl.com/10bc2201810181324424582.jpg',
        title: '从0学英语，只要30天'
      },
      index_list: [
        {
          class: 1,
          cover: 'http://ww1.sinaimg.cn/large/663d3650gy1fq66vvsr72j20p00gogo2.jpg',
          title: '「学习雷锋好榜样」主题课程，90天变成大善人！',
          name: '雷锋',
          long: '60课'
        },
        {
          class: 1,
          cover: 'http://ww1.sinaimg.cn/large/663d3650gy1fq66vvsr72j20p00gogo2.jpg',
          title: '「学习雷锋好榜样」主题课程，90天变成大善人！',
          name: '雷锋',
          long: '60课'
        }
      ]
    }
  },

  components: {
    SwiperItem,
    Search,
    Group,
    Cell,
    XButton,
    Swiper,
    curriculum
  },
  created () {
    this.getext()
  },
  computed: {
    ...mapState({
      app_id: state => state.app_id,
      user_id: state => state.member_id
    })
  },
  methods: {
    gotype (item) {
      // console.log(item.classification_id)
    },
    getext () {
      this.indexObj.app_id = this.app_id
      this.indexObj.user_id = this.user_id
      let obj = {
        app_id: this.indexObj.app_id
      }
      api.post('/wechat/Authorize/get_online', obj).then(res => {
        if (res.data.code === 200) {
          this.bannerlist = JSON.parse(res.data.data.json).ext.styles[0].index.elements[0].imgUrls
          // console.log(this.bannerlist)
          // console.log(JSON.parse(res.data.data.json).ext.styles[0].index.elements)]
          // 123
        }
      })
    },
    demo01_onIndexChange (index) {
      this.demo01_index = index
    }
  },
  mounted () {
    // console.log(this.app_id)
  }
}

</script>

<style scoped lang="css">
  @import '../../assets/css/index.css'
</style>
